/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jmodcog2.util;

import java.util.Random;

/**
 *
 * @author Mitch
 */
public final class WeightGen {
    public static final Random ran = new Random();
    
    private WeightGen() {
        
    }
    
    public static float weight_uniform_pos() {
        return ran.nextFloat();
    }
    
    public static float weight_uniform() {
        return ran.nextFloat() * 2f - 1f;
    }
    
    public static double weight_gauss_pos() {
        return Math.max(-1, Math.min(1, ran.nextGaussian()/Math.E)) * 0.5f + 0.5f;
    }
    
    public static double weight_gauss() {
        return Math.max(-1, Math.min(1, 0.5 * (ran.nextGaussian()/Math.E) + 0.5));
    }
    
    public static double weight_2D_gauss(float dx, float dy) {
        return weight_gauss()/(dx*dx + dy*dy + 1.0);
    }
    
    public static double weight_2D_gauss_pos(float dx, float dy) {
        return weight_gauss_pos()/(dx*dx + dy*dy + 1.0);
    }
    
    public static double weight_2d_locality(float dx, float dy) {
        return 1f/(1f + (dx * dx + dy * dy));
    }
}
